package jps_s10996_s7175;

import jps_s10996_s7175.ast.*;
import jps_s10996_s7175.expression.binary.*;
import jps_s10996_s7175.expression.terminal.*;
import jps_s10996_s7175.expression.unary.*;

/**
 *
 * Class description goes here.
 *
 * @author Kamil Gajowy
 */
public class AST {


    /**
    * Default constructor.
    */
    public AST(){

    }

    public static void execute() {
        System.out.println("------------");
        System.out.println("Firma where (avg(zatrudnia.pensja) > 2550.50)");
        System.out.println("------------");

        Expression ex1 =
                new WhereExpression(
                        new NameTerminal("firma"),
                        new GreaterThanExpression(
                                new AvgExpression(
                                        new DotExpression(
                                                new NameTerminal("zatrudnia"),
                                                new NameTerminal("pensja")
                                        )
                                ),
                                new DoubleTerminal(2550.50)
                        )
                );
        System.out.println(ex1.toString());

        System.out.println("------------");
        System.out.println("Pracownik where (adres.miasto in (bag(Warszawa, \"Łódź\")))");
        System.out.println("------------");

        Expression ex2 =
                new WhereExpression(
                        new NameTerminal("pracownik"),
                        new InExpression(
                                new DotExpression(
                                        new NameTerminal("adres"),
                                        new NameTerminal("miasto")
                                        ),
                                new BagExpression(
                                        new CommaExpression(
                                                new StringTerminal("Warszawa"),
                                                new StringTerminal("Łódź")
                                                )
                                        )

                        )
                );
        System.out.println(ex2.toString());

        System.out.println("------------");
        System.out.println("bag(1,2+1) in bag(4-1,3-2)");
        System.out.println("------------");

        Expression ex3 =
                new InExpression(
                        new BagExpression(
                                new CommaExpression(
                                        new IntegerTerminal(1),
                                        new PlusExpression(
                                                new IntegerTerminal(2),
                                                new IntegerTerminal(1)
                                                )
                                        )
                                ),
                        new BagExpression(
                                new CommaExpression(
                                        new MinusExpression(
                                                new IntegerTerminal(4),
                                                new IntegerTerminal(1)
                                                ),
                                        new MinusExpression(
                                                new IntegerTerminal(3),
                                                new IntegerTerminal(2)
                                        )
                                )


                        )
                );
        System.out.println(ex3.toString());

        System.out.println("------------");
        System.out.println("(Pracownik where nazwisko=\"Kowalski\").(adres where miasto=\"Łódź\")");
        System.out.println("------------");

        Expression ex4 =
                new DotExpression(
                        new WhereExpression(
                                new NameTerminal("pracownik"),
                                new EqualsExpression(
                                        new NameTerminal("nazwisko"),
                                        new StringTerminal("Kowalski")
                                        )
                                ),
                         new WhereExpression(
                                 new NameTerminal("adres"),
                                 new EqualsExpression(
                                         new NameTerminal("miasto"),
                                         new StringTerminal("Łódź")
                                         )
                                 )
                        );
        System.out.println(ex4.toString());
    }

}//end class
